<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="common.jsp"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html>
<html>
<head>
<title>呼叫</title>
<script src="${ctx}/jiaohao/amq_jquery_adapter.js"></script>
<script src="${ctx}/jiaohao/amq.js"></script>
<script src="${ctx}/jiaohao/jquery.json-2.2.js"></script>
<script type="text/javascript">
	
	//s1.查询诊台对应的诊室、科室
	//s2.加载消息推送过来的诊室对应的病人信息（当前呼叫的和等待就诊的三个病人）
	$(function () {
		var topic = $("#topic").val();
		$.ajax({
			url:rootUrl + "/clidoctor/selectDataByScriptId",
			type:'get',
			dataType:'json',
			async:false,
			data:{ ID:10000020, paramStr:'{triage_id:'+topic+'}'},
			success:function(data)
			{
				debugger;
				var bas1List = data.list;
				var html = "";
				for(var i=0;i<bas1List.length;i++)
				{
					var temp = bas1List[i];
					html += '<tr><td colspan="7" height="10px" class="td_line"></td></tr>';
					html += '<tr id="'+temp.bas01+'"><td class="td_line"><div class="skill"><div class="skillbar1"></div></div></td>';
					html += '<td class="trline01">'+temp.bas02+'</td>';
					html += '<td class="trline01">'+temp.bck03+'</td>';
					html += '<td class="trline01 bce03a"></td>';
					html += '<td class="trline01 vaa05"></td>';
					html += '<td class="trline01 td_line"></td>';
					html += '<td class="td_line"><div class="skill"><div class="skillbar2 dengdai_bingren"></div></div></td>';
					html += '</tr>';
				}
				$("#jiaohaoTr").html(html);
			}
		});
		var amq = org.activemq.Amq;  
		amq.init({   
		  uri: 'amq', 
		  logging: true,
		  timeout: 5
		}); 
		var myHandler = function (message) 
		{
			debugger;
			var html;
			$("#msgDiv").empty();
			$("#msgDiv").append(unescape(message.data.replace(/\u/g, "%u")).replace("\\",''));
			var msgData = JSON.parse(message.data);
			var obj = msgData.hJrow;
			var obj2 = msgData.hJrow2;
			var houzhenList = msgData.houzhenList;
			$("#"+obj.bas01).find(".vaa05").text(obj.vaa05);
			$("#"+obj.bas01).find(".bce03a").text(obj.bce03a);
			//等待的病人
			var obj1 = houzhenList[1];
			var obj2 = houzhenList[2];
			var obj3 = houzhenList[3];
			var dengdai_bingren = obj1?obj1.vaa05:"" + obj2?obj2.vaa05:"" + obj3?obj3.vaa05:"";
			$("#"+obj.bas01).find(".dengdai_bingren").text(dengdai_bingren);
		}
		amq.addListener("smeguangdong","topic://"+topic,myHandler);
	});
</script>
<link href="${ctx}/jiaohao/成都中医大银海眼科医院/css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<input type="hidden" id="topic" value="<%=request.getParameter("topic")%>"/>
	<div id="msgDiv" style="display: none;"></div>
    <div class="header">
      <div class="topcenter">
      </div> 
      <div class="topright">
        <span>2017年3月15日 星期三</span>
      </div>       
    </div>
    <!--顶部的结束-->
     <div class="formbody">
        <div class="maininfo">
           <table class="imgtable">
            <thead>
            <tr>
                <th width="1%">&nbsp;</th>
                <th width="2%">诊室</th>
                <th width="2%">科室</th>
                <th width="2%">医生</th>
                <th width="2%">正在就诊</th>
                <th width="5%">等待就诊</th>
                <th width="2%">&nbsp;</th>
            </tr>
            </thead>
            <tbody id="jiaohaoTr">
            </tbody>
            </table>
        </div>
      </div>
   <!--中间区域结束-->
   <div class="footer">
     请在候诊厅等待就诊，保持安静，不要走开，祝您早日康复。
   </div>
</body>

</html>
